var LookUpHospID="null"; // LookUpLoc.tag中使用
/**
 * 初始化病房详情对话框
 */
var CdcRoomInfoDlg = {
    validateFields: {
    	code: {
            validators: {
                notEmpty: {
                    message: '代码不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	locationId: {
            validators: {
                notEmpty: {
                    message: '所属病区不能为空'
                }
            }
        },
    	busRoomTypeId: {
            validators: {
                notEmpty: {
                    message: '房间类型不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcRoomInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcRoomInfoDlg.validate = function () {
    $('#cdcRoomInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcRoomInfoForm').bootstrapValidator('validate');
    return $("#cdcRoomInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcRoomInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcRoomInfoForm',Sys.backendPath + "/cdc/cdcroom/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcRoom.table.refresh();
        CdcRoomInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcRoomInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcRoomInfoForm',Sys.backendPath + "/cdc/cdcroom/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcRoom.table.refresh();
        CdcRoomInfoDlg.close();
    });
}

CdcRoomInfoDlg.selectHosp = function(id,record) {
    LookUpHospID=record.value;
    $("#lookup_locationId").lookup("enable");
}

$(function() {
	Sys.initValidator("cdcRoomInfoForm", CdcRoomInfoDlg.validateFields);
    $("#dataId").combobox("disable");
    $("#dataId").combobox('setValue', window.parent.CdcRoom.sysDataId);
    if(!$("#hospitalId").val()) {
        $("#lookup_locationId").lookup("disable");
    }else{
        LookUpHospID=$("#hospitalId").val();
    }
});
